package middleware

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"mall-go/response"
)

// RecoverMiddleware 这个中间件可以将错误返回给前端/*
func RecoverMiddleware() gin.HandlerFunc {
	return func(context *gin.Context) {
		defer func() {
			if err := recover(); err != nil {
				response.Failure(context, nil, fmt.Sprint(err))
			}
		}()

		context.Next()
	}
}
